<?php



/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Game
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
 
class Game_Form_Helper
{

  public static function getContentField($name, $options = array())
  {
    static $content_fields = null;
    
    if ($content_fields === null)
    {
      $content_fields = array(
      
        'title' => array(
                'Text',
                'title',
                array(
                  'label' => 'Title',
                )
              ),
        'max' => array(
                'Text',
                'max',
                array(
                  'label' => 'Max Items',
                  'value' => 5,
                ),
              ),
        'user_type' => array(
                'Radio',
                'user_type',
                array(
                    'label' => 'User',
                    'multiOptions' => array(
                      'owner' => 'OWNER - game\'s created by owner of the current viewing page',
                      'viewer' => 'VIEWER - game\'s created by the current active logged in member',
                    ),
                    'value' => 'owner',
                  ),
                ),
        'game' => array(
                'Text',
                'game',
                array(
                  'label' => 'Game ID',
                )
              ),              
        'user' => array(
                'Text',
                'user',
                array(
                  'label' => 'User',
                )
              ),
        'keyword' => array(
                'Text',
                'keyword',
                array(
                  'label' => 'Keywords',
                )
              ),
        'category' => array(
                'Select', 
                'category',
                array(
                  'label' => 'Category',
                  'multiOptions' => array(""=>"") + Engine_Api::_()->getItemTable('game_category')->getMultiOptionsAssoc(),
                )
              ), 
        'max_width' => array(
                'Text',
                'max_width',
                array(
                  'label' => 'Max Width',
                  'value' => 700,
                )
              ),
        'order' => array(
                'Select', 
                'order',
                array(
                  'label' => 'Sort By',
                  'multiOptions' => self::getOrders(),
                  'value' => 'recent',
                )
              ),
        'period' => array(
                'Select', 
                'period',
                array(
                  'label' => 'Time Period',
                  'multiOptions' => self::getPeriods(),
                )
              ),
        'display_style' => array(
                'Radio',
                'display_style',
                array(
                  'label' => 'Display Style',
                  'multiOptions' => array(
                    'wide' => "Wide (main middle column)",
                    'narrow' => "Narrow (left / side side column)",
                  ),
                  'value' => 'wide',
                )
              ),
        'showphoto' => array(
                'Select', 
                'showphoto',
                array(
                  'label' => 'Show Photo',
                  'multiOptions' => self::getYesNo(),
                  'value' => 1,
                )
              ),  
        'showdetails' => array(
                'Select', 
                'showdetails',
                array(
                  'label' => 'Show Details',
                  'multiOptions' => self::getYesNo(),
                  'value' => 1,
                )
              ), 
        'showmeta' =>  array(
                'Select', 
                'showmeta',
                array(
                  'label' => 'Show Meta',
                  'multiOptions' => self::getYesNo(),
                  'value' => 1,
                )
              ), 
        'showdescription' =>  array(
                'Select', 
                'showdescription',
                array(
                  'label' => 'Show Description',
                  'multiOptions' => self::getYesNo(),
                  'value' => 1,
                )
              ),  
        'featured' => array(
                'Select', 
                'featured',
                array(
                  'label' => 'Show only featured games?',
                  'multiOptions' => self::getYesNo(),
                  'value' => 0,
                )
              ),
        'sponsored' => array(
                'Select', 
                'sponsored',
                array(
                  'label' => 'Show only sponsored games?',
                  'multiOptions' => self::getYesNo(),
                  'value' => 0,
                )
              ),     
        'content_rating' => array(
                'Select', 
                'content_rating',
                array(
                  'label' => 'Content Rating',
                  'multiOptions' => array(""=>"") + self::getContentRatings(),
                )
              ),
              
        'distributor_type' => array(
                'Select', 
                'distributor_type',
                array(
                  'label' => 'Distributor Type',
                  'multiOptions' => array(""=>"") + self::getDistributorTypes(),
                )
              ),   
        'leaderboard_enabled' => array(
                'Select', 
                'leaderboard_enabled',
                array(
                  'label' => 'Show only leaderboard enabled games?',
                  'multiOptions' => self::getYesNo(),
                  'value' => 0,
                )
              ),      
        'showemptyresult' => array(
            'Select', 
            'showemptyresult',
            array(
              'label' => 'Show Empty Result',
              'multiOptions' => self::getYesNo(),
              'value' => 0,
            )
          ),
        'showmemberitemlist' => array(
            'Select', 
            'showmemberitemlist',
            array(
              'label' => 'Show Member\'s Game Link',
              'multiOptions' => self::getYesNo(),
              'value' => 1,
            )
          ),
        'showlinkall' => array(
            'Select', 
            'showlinkall',
            array(
              'label' => 'Show Link All',
              'multiOptions' => self::getYesNo(),
              'value' => 1,
            )
          ),
      );
    }
    if (array_key_exists($name, $content_fields)) {
      $field = $content_fields[$name];
    }
    else {
      $field = array(
        'Text',
        $name,
        array(
          'label' => $name
        ),
      );
    }
    
    $keys = array('value', 'label', 'multiOptions');
    foreach ($options as $key => $value) {
      if (in_array($key, $keys)) {
        $field[2][$key] = $value;
      }
    }
    
    return $field;
  }
 
  public static function getStatuses()
  {
    $options = array(
      Game_Model_Game::STATUS_PUBLISHED => 'Published',
      Game_Model_Game::STATUS_PENDING => 'Pending',
      Game_Model_Game::STATUS_DISABLED => 'Disabled',
    );
    return $options;
  }
  
  public static function getContentRatings()
  {
    $options = array(
      Game_Model_Game::CONTENT_RATING_EVERYONE => 'Everyone',
      Game_Model_Game::CONTENT_RATING_TEEN => 'Teen',
      Game_Model_Game::CONTENT_RATING_MATURE => 'Mature',
    );
    return $options;
  }
  
  public static function getDistributorTypes()
  {
    $options = array(
      'manual' => 'Manual',
      'mochi' => 'Mochi Media',
      'kongregate' => 'Kongregate',
    );
    return $options;
  }
  
  public static function getOrders()
  {
    $options = array(
      'recent' => 'Most Recent',
    	'lastupdated' => 'Last Updated',
    	'alphabet' => 'Game Title',
      'mostfavorited' => 'Most Favorited',
    	'mostviewed' => 'Most Viewed',
      'mostcommented' => 'Most Commented',
      'mostliked' => 'Most Liked',
      'random' => 'Randomized',
    );
    return $options;
  }
  
  public static function getYesNo()
  {
    $options = array(
                1 => 'Yes',
                0 => 'No'
              );
    return $options;
  }
  
  public function getPeriods()
  {
    $options = array(
      'all' => 'All Time',
      '24hrs' => 'Last 24 Hours',
      'week' => '7 Days',
      'month' => '30 Days',
      'quarter' => '3 Months',
      'year' => '12 Months',
    );
    return $options;
  }
  
  public function getFileLinkTypes()
  {
    $options = array(
        '1' => 'Uploaded',
        '0' => 'Hotlinked',
    );
    return $options;
  }
}